<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>采购单商品入库</title>
</head>
<body>
<div class="container">

   <div class="comm_content">

            <div  >
                <form id="searchForm" class="form-inline" onsubmit="return false;">
                    <div class="panel panel-default">

                        <div class="panel-heading"><h3 class="panel-title">入库商品信息</h3></div>
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th width="*">商品名称</th>
                                <th width="120" style="text-align: left;">商品编号</th>
                                <th width="150" style="text-align: center;">入库数量</th>
                                <th width="230" style="text-align: center;">备注</th>
                            </tr>
                            </thead>
                            <tbody id="general_line">
                            <!--{foreach from=$dunch_apply_detail item=send_date key=i}-->
                            <tr class="success" id="goods_<!--{$i}-->">
                                <td><label id="goodsName_<!--{$i}-->"><!--{$send_date.product_name}--></label></td>
                                <td><label id="product_code_<!--{$i}-->"><!--{$send_date.product_code}--></label></td>
                                <td><input type="text" class="form-control input-sm" maxlength="6" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:140px" value="" name="amount_<!--{$i}-->" id="amount_<!--{$i}-->" placeholder="<!--{$send_date.apply_amount}-->"></td>
                                <td><input type="text" class="form-control input-sm" maxlength="200"  style="width:200px" name="remark_<!--{$i}-->" id="remark_<!--{$i}-->"></td>
                            </tr>
                            <!--{/foreach}-->
                            </tbody>
                        </table>
                    </div>
                </form>
                <div class="bottom_fixbox">
        			<div class="tac" style="background: #dddddd;">
           			<input type="button" class="btn btn-primary" onclick="coupon.add();" value="入库" />&nbsp;&nbsp;&nbsp;
            		<input type="button" class="btn btn-default" onclick="E.closeWindows();" value="关闭" />
        		</div>
            </div>
        </div>
            <input type="hidden" id="cityName"/>
            <input type="hidden" id="distribution_name"/>
        </div>

</div>

<script type="text/javascript">

    var coupon = {
        choose_data: { },
        general_goods:{ },

        add : function(){
            var msg="";
            var msg2="";
            //获取普通商品的信息
            $.each($("#general_line tr"),function(k,v){
                coupon.general_goods[k] = {
                    product_code : $("#product_code_"+k).html(),
                    product_name : $("#goodsName_"+k).html(),
                    paid_amount : $("#amount_"+k).val(),
                    remark : $("#remark_"+k).val()
                }

                if($("#amount_"+k).val()==""){
                    msg+="请输入"+$("#goodsName_"+k).html()+"入库数量</br>";
                }
               /* else if($("#amount_"+k).val() > parseInt($("#amount_"+k).attr("placeholder"))){
                    msg2+=$("#goodsName_"+k).html()+"入库数量大于申请数量</br>";
                }*/
            });


            if(msg !=''){
                E.alert(msg);
                return false;
            }
            E.ajax_post({
                url: "/invokingAjax-backend/production/applySearch.ajax?operFlg=5",
                data: {
                    applyID : <!--{$applyID}-->,
                    general_goods:coupon.general_goods
                },
                call: function(data){
                    if(data.code=200){

                        E.alert('商品入库成功',2);
                        E.opener('coupon.search');
                        E.closeWindows();
                    }else{
                        E.alert(data.message);
                    }

                }
            });

        }

    };



</script>

</body>
</html>